<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>二进制</title>
</head> 
<body>
  <script>
    var number = Math.floor(Math.random()*100 + 1);
    var str="";
    for (var i = number; i > 1; parseInt(i /= 2)) {
      str = parseInt(i % 2) + str;
    }
    console.log(number);
    console.log(str)

  </script>
</body>
</html>